# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: dorphell <dorphell@archlinux.org>

pkgname=zip
pkgver=3.0
_pkgver=${pkgver/./}
pkgrel=9
pkgdesc='Compressor/archiver for creating and modifying zipfiles'
url='http://www.info-zip.org/Zip.html'
arch=('x86_64')
license=('custom')
depends=('bzip2')
source=("https://downloads.sourceforge.net/infozip/${pkgname}${_pkgver}.tar.gz"
        'zipnote.patch')
sha256sums=('f0e8bb1f9b7eb0b01285495a2699df3a4b766784c1765a8f1aeedf63c0806369'
            '89249a3f1fdf838b795ce432a2d763fdbe913d6a146541e41b7a2e2769291ba0')

options=('!makeflags')

prepare() {
	cd "${srcdir}/${pkgname}${_pkgver}"
	sed -e "/^CFLAGS_NOOPT =/s/\$/ $CPPFLAGS $CFLAGS/" -i unix/Makefile
	sed -e "s/^LFLAGS1=''/LFLAGS1=$LDFLAGS/" -i unix/configure
	patch -p1 -i ../zipnote.patch
}

build() {
	cd "${srcdir}/${pkgname}${_pkgver}"
	make -f unix/Makefile prefix=/usr generic_gcc
}

package() {
	cd "${srcdir}/${pkgname}${_pkgver}"
	make -f unix/Makefile prefix="${pkgdir}"/usr \
		MANDIR="${pkgdir}"/usr/share/man/man1 \
		install
	install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
